package ThreadDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-09-06
 * Time: 11:10
 */
//使用匿名内部类来创建线程
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(){
            @Override
            public void run(){
                System.out.println("I am New Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        };
        t.start();

        while(true){
            System.out.println("Main thread");
            Thread.sleep(1000);
        }
    }
}
